package com.wx.cloud.user.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean
    public Queue rabbitQueue() {
        return new Queue("springboot.rabbit",true);
    }

    @Bean
    TopicExchange registerTopicExchange() {
        return new TopicExchange("wx.springboot.java",true,false);
    }

    @Bean
    Binding rabbitQueueToJavaDirectExchange() {
        return BindingBuilder.bind(rabbitQueue()).to(registerTopicExchange()).with("qw.queue");
    }


    @Bean
    MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }

}
